/*
 * @Author: zhouwei wei.zhou@flip.fun
 * @Date: 2024-04-07 23:35:15
 * @LastEditors: zhouwei wei.zhou@flip.fun
 * @LastEditTime: 2024-04-07 23:46:21
 * @FilePath: /50/手撕系列/call.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
function apply(obj, args = []) {
    if (typeof this !== 'function') {
        return new Error('Call must be a function');
    }
	const fnKey = Symbol()
    const ctx = obj || window
	const fn = this
	ctx[fnKey] = fn
	ctx[fnKey](...args)
	Reflect.deleteProperty(ctx, fnKey)
}
Function.prototype.myApply = apply
function setAge(age) {
	this.age = age
}
const obj = {
	age: 22,
}
setAge.apply(obj, [11])
console.log(obj)
